﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;
using System.IO;
using DataAccessEntLib;

public partial class ChooseLocation : System.Web.UI.Page
{
    RegistrationData regdata = new RegistrationData();
    string Link = string.Empty, strCode = string.Empty;
    HttpPostedFile myFileHeader = null;
    BusinessLogic busin = new BusinessLogic();
    const string constUser = "User";
    int UserID = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindCountry();
        } 
    }

    protected void btnSave_Click(object sender, ImageClickEventArgs e)
    {


        if (ddlCountry.SelectedIndex != 0)
        { 
            string ID = string.Empty;
            ID = ddlCountry.SelectedItem.Value.ToString();


            HttpCookie myCookie = new HttpCookie("countryid", ID);
            myCookie.Expires = DateTime.Now.AddMonths(1);
            Response.Cookies.Add(myCookie);

            string script = string.Format("javascript:window.parent.location = 'default.aspx';parent.$.fancybox.close();");
            ScriptManager.RegisterStartupScript(this, this.GetType(), "alertScript", script, true);
            //lblMessage.Text = "Location Saved Successfully";
            //btnCancel.Attributes.Add("onclick", "javascript:window.parent.location = 'default.aspx';");
            //btnCancel.Attributes.Add("src", "images/close.jpg");
        }
        else
        {
            lblMessage.Text = "Please Select Country";
        }
    }

    BLL.AdMagnager bll = new BLL.AdMagnager();

    protected void BindCountry()
    {
        IDataReader dr;
        ddlCountry.Items.Clear();
        ListItem lst1 = new ListItem();
        lst1.Text = "Select";
        lst1.Value = "0";
        ddlCountry.Items.Add(lst1);
        dr = bll.SelectCountryMaster();
        if (dr != null)
        {
            while (dr.Read())
            {
                ListItem lst = new ListItem();
                lst.Text = dr["CountryName"].ToString();
                lst.Value = dr["ID"].ToString();
                ddlCountry.Items.Add(lst);
            }
        }
        dr.Close();
    }

}